<?php echo $this->element('admin_header'); ?>
<div class="portfolios index">
<h2><?php __('Portfolios');?></h2>

<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Portfolio', true), array('action'=>'add')); ?></li>
		<li><?php echo $html->link(__('List Category', true), array('controller'=>'categories','action'=>'index')); ?></li>
		<li><?php echo $html->link(__('New Category', true), array('controller'=>'categories','action'=>'add')); ?></li>
		<li><?php echo $html->link(__('List Uploads', true), array('controller'=>'uploads','action'=>'index')); ?></li>
		<li><?php echo $html->link(__('New Upload', true), array('controller'=>'uploads','action'=>'add')); ?></li>
	</ul>
</div>

<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th>Category</th>
	<th>Uploads</th>
	<th><?php echo $paginator->sort('title');?></th>
	<th><?php echo $paginator->sort('customer');?></th>
	<th><?php echo $paginator->sort('work_place');?></th>
	<th><?php echo $paginator->sort('url');?></th>
	<th><?php echo $paginator->sort('description');?></th>
	<th><?php echo $paginator->sort('date');?></th>
	<th><?php echo $paginator->sort('views');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($portfolios as $portfolio):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php foreach($portfolio['Category'] as $category):?>
			<?php echo $html->link($category['title'], array('action'=>'index', $category['slug'])); ?>
			<?php endforeach; ?>
		</td>
		<td>
			<?php foreach($portfolio['Upload'] as $upload):?>
			<?php if(!empty($upload['filename'])) {
				echo $lightbox->img(null, $upload['dir'] . DS . $upload['filename'], array('title' => $upload['title']), array(), 'thumb');
			} ?>
			<?php endforeach; ?>
		</td>
		<td>
			<?php echo $html->link($portfolio['Portfolio']['title'], array('action'=>'view', $portfolio['Portfolio']['slug'])); ?>
			<?php echo $portfolio['Portfolio']['title']; ?>
		</td>
		<td>
			<?php echo $portfolio['Portfolio']['customer']; ?>
		</td>
		<td>
			<?php echo $portfolio['Portfolio']['work_place']; ?>
		</td>
		<td>
			<?php echo $html->link($portfolio['Portfolio']['url'], $portfolio['Portfolio']['url']); ?>
		</td>
		<td>
			<?php echo $textile->TextileThis($portfolio['Portfolio']['description']); ?>
		</td>
		<td>
			<?php echo $time->niceShort($portfolio['Portfolio']['date']) ?>
		</td>
			<td>
				<?php echo $portfolio['Portfolio']['views'] ?>
			</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('action'=>'view', $portfolio['Portfolio']['id'])); ?>
			<?php echo $html->link(__('Edit', true), array('action'=>'edit', $portfolio['Portfolio']['id'])); ?>
			<?php echo $html->link(__('Delete', true), array('action'=>'delete', $portfolio['Portfolio']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $portfolio['Portfolio']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Portfolio', true), array('action'=>'add')); ?></li>
		<li><?php echo $html->link(__('List Category', true), array('controller'=>'categories','action'=>'index')); ?></li>
		<li><?php echo $html->link(__('New Category', true), array('controller'=>'categories','action'=>'add')); ?></li>
		<li><?php echo $html->link(__('List Uploads', true), array('controller'=>'uploads','action'=>'index')); ?></li>
		<li><?php echo $html->link(__('New Upload', true), array('controller'=>'uploads','action'=>'add')); ?></li>
	</ul>
</div>
